package gao.xiaolei.dao;

import gao.xiaolei.entity.TestTeamGrade;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository("TestTeamGradeDao")
public interface TestTeamGradeDao extends JpaRepository<TestTeamGrade,String> {

    @Modifying
    public void deleteAllByProject(String project);

    @Query("select grade from TestTeamGrade where project=:project and teamId=:teamId")
    public Integer getGradeByProjectAndTeamId(@Param("project") String project,
                                              @Param("teamId") String teamId);

    @Modifying
    @Query("update TestTeamGrade set grade=:grade where project=:project and teamId=:teamId")
    public void updateTeamGrade(@Param("project") String project,
                                @Param("teamId") String teamId,
                                @Param("grade") Integer grade);
}
